class StorageManger {
    get<T>(key: string) {
        let data = window.localStorage.getItem(key);
        if (data) {
            let json = JSON.parse(data);
            return json as T;
        }
        return undefined;
    }

    set<T = any>(key: string, value: T) {
        let json = JSON.stringify(value);
        window.localStorage.setItem(key, json);
    }

    remove(key: string) {
        window.localStorage.removeItem(key);
    }

    clear() {
        window.localStorage.clear();
    }
}

export default new StorageManger();
